package com.serkol.ams.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.serkol.ams.bean.MyPage;
import com.serkol.ams.bean.MyPageOld;
import com.serkol.ams.entity.UsersWalletIntegralLog;
import com.serkol.ams.mapper.UsersWalletIntegralLogMapper;
import com.serkol.ams.service.UsersWalletIntegralLogService;
import com.serkol.handler.MyLambdaQueryWrapper;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
* @author pingan
* @description 针对表【users_wallet_integral_log】的数据库操作Service实现
* @createDate 2022-10-17 17:08:52
*/
@Service
public class UsersWalletIntegralLogServiceImpl extends ServiceImpl<UsersWalletIntegralLogMapper, UsersWalletIntegralLog>
    implements UsersWalletIntegralLogService{

    @Override
    public MyPage<Map<String, Object>> findByBackLogList(int pageSize, int current, int state, long userId) {
        MyLambdaQueryWrapper<UsersWalletIntegralLog> queryWrapper = new MyLambdaQueryWrapper<>();
        queryWrapper.authName(UsersWalletIntegralLog::getUserId).as("name").select(UsersWalletIntegralLog::getIntegral, UsersWalletIntegralLog::getIntegraln, UsersWalletIntegralLog::getIntegralOld, UsersWalletIntegralLog::getRemark, UsersWalletIntegralLog::getCreateDate,UsersWalletIntegralLog::getType).attr("usersblancewithdrawaltype", UsersWalletIntegralLog::getState).as("stateName").authName(UsersWalletIntegralLog::getOperatorId).as("operatorName");
        queryWrapper.orderByDesc(UsersWalletIntegralLog::getCreateDate);
        if(userId>0){
            queryWrapper.eq(UsersWalletIntegralLog::getUserId, userId);
        }
        if (state > 0) {
            queryWrapper.eq(UsersWalletIntegralLog::getState, state);
        }
        Page<Map<String, Object>> page = new Page<>(current, pageSize);
        IPage<Map<String, Object>> data = this.baseMapper.selectMapsPage(page, queryWrapper);

        return MyPage.parsePage(data);
    }
}




